#include <signal.h>
#include <QApplication>

#include <QtGui>
#include "PopupGuiCore.hpp"

static void signalHandler(int)
{
  PopupGuiCore::instance()->exit();
}

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    QApplication::setQuitOnLastWindowClosed(false);

    QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
    QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
    QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));

    QString locale = QLocale::system().name().section('_', 0, 0);
    QTranslator translator;
    translator.load(QString(":/lang/popup_") + locale);
    app.installTranslator(&translator);

    PopupGuiCore::instance();

#ifdef _LINUX
    ::signal(SIGINT, signalHandler);
    ::signal(SIGTERM, signalHandler);
    ::signal(SIGKILL, signalHandler);
#endif

    return app.exec();
}
